//
// Created by user on 2022/1/17.
//
#include <iostream>
#include <vector>
using namespace std;
bool checkPossibility(vector<int>& nums) {

    int n = nums.size();
    int cnt = 0;
    for (int i = 1; i <n ; ++i) {

        if(nums[i]<nums[i-1]){
            cnt++;
            if(cnt>1){return false;}
            if(i - 2 >= 0 && nums[i] < nums[i - 2]){nums[i]=nums[i-1];}
            else{nums[i-1]=nums[i];}
        }
    }
    return true;
}
